#! /usr/bin/env bash

date -Iseconds

# environment args
VERSION=${1:-v2.12.17-beta-0fa83b7}    
CURDIR="`dirname $0`" #获取此脚本所在目录
       # 版本号
CONTAINER_NAME=dag-dji-dock            # 容器名
DATA_DIR=${CURDIR}/dagData  # 对接层目录
NETWORK=host
PORT_IN_HOST=6789

export IMAGE_NAME=registry.cn-shenzhen.aliyuncs.com/dyi/aircraft:dag-dji-docker-sample.${VERSION}

docker network create ${NETWORK}

docker rm -f ${CONTAINER_NAME} >/dev/null 2>&1

(
    docker run --restart=always -d --name ${CONTAINER_NAME}\
      --network=host \
      --log-opt max-size=1g \
      --log-opt max-file=1 \
      -p 0.0.0.0:${PORT_IN_HOST}:6789 \
      --privileged \
      -v "${DATA_DIR}":/app/data \
      "${IMAGE_NAME}"
)
echo "image: ${IMAGE_NAME}" &&
date -Iseconds &&
echo -e "\n"
